package com.deer.backup.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.deer.backup.result.Result;
import com.deer.backup.result.ResultController;
import com.deer.backup.service.SetupsService;
import com.deer.backup.vo.Setups;

@RestController
@RequestMapping("/setups")
public class SetupsController extends ResultController{
	
    @Autowired
    private SetupsService setupsService;

    
    // 跳转配置添加、修改页面
    @GetMapping("/edit")
    public ModelAndView editview(ModelMap map) {
    	Setups setups = setupsService.getOne();
    	map.put("setups", setups);
        return jumpPage("setups/edit");
    }

    // 更新配置数据
    @ResponseBody
    @PutMapping("/save")
    public Result<?> updateBackUpById(@RequestBody Setups setups) {
        return decide(setupsService.saveOrUpdate(setups));
    }


}